<template>
  <ul class="todo-main">
    <row-index :msgList="msgList" @addevent="addeventlist(index)"></row-index>
  </ul>
</template>

<script>
// 引入展示每一行数据的子组件
import rowIndex from "./row.vue";
export default {
  name: "listIndex",
  components: {
    rowIndex,
  },
  watch: {
    msgList: {
      handler(newV, oldV) {
        this.$BUS.$emit("footerData", this.msgList);
      },
      deep: true,
    },
  },
  data() {
    return {
      msgList: [], //任务数据列表
    };
  },
  mounted() {
    // 1.监听新增任务信息
    this.$BUS.$on("addMsg", (msg) => {
      this.msgList.push(msg);
    });
    this.$BUS.$on("allstatusaaa", (msg1) => {
      this.msgList.forEach((item) => {
        item.status = msg1;
      });
    });
  },
  methods: {
    addeventlist(index) {
      this.msgList.splice(index, 1);
    },
  },
};
</script>

<style scoped>
.todo-main {
  margin-left: 0px;
  border: 1px solid #ddd;
  border-radius: 2px;
  padding: 0px;
}

.todo-empty {
  height: 40px;
  line-height: 40px;
  border: 1px solid #ddd;
  border-radius: 2px;
  padding-left: 5px;
  margin-top: 10px;
}

/*item*/
li {
  list-style: none;
  height: 36px;
  line-height: 36px;
  padding: 0 5px;
  border-bottom: 1px solid #ddd;
}

li label {
  float: left;
  cursor: pointer;
}

li label li input {
  vertical-align: middle;
  margin-right: 6px;
  position: relative;
  top: -1px;
}

li button {
  float: right;
  display: none;
  margin-top: 3px;
}

li:before {
  content: initial;
}

li:last-child {
  border-bottom: none;
}

.btn {
  display: inline-block;
  padding: 4px 12px;
  margin-bottom: 0;
  font-size: 14px;
  line-height: 20px;
  text-align: center;
  vertical-align: middle;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 1px 2px rgba(0, 0, 0, 0.05);
  border-radius: 4px;
}

.btn-danger {
  color: #fff;
  background-color: #da4f49;
  border: 1px solid #bd362f;
}

.btn-danger:hover {
  color: #fff;
  background-color: #bd362f;
}

.btn:focus {
  outline: none;
}
</style>
